﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
    <meta http-equiv="expires" content="0" />
    <title>FaceCat</title>
</head>
<body>
    <canvas id="mycanvas" width="1000" height="700" style="position: fixed; left: 0px; top: 0px;"/>
    <script type="text/javascript" src="facecat.js"></script>
    <script type="text/javascript">
        let canvas = document.getElementById("mycanvas"); //绘图区域
        let gPaint = new FCPaint(); //绘图对象
        gPaint.canvas = canvas;
        scaleCanvas(gPaint);
        //判断是否移动端
        gPaint.isMobile = isMobileMode();
        if (gPaint.isMobile) {
            gPaint.scaleFactorX = 2.5;
            gPaint.scaleFactorY = 2.5;
        }
        addDefaultEvent(canvas, gPaint);
        class MyView extends FCView {
            constructor() {
                super();
            }
        };

        let backView  = new FCView();
        backView.dock = "fill";
        backView.backColor = "rgb(255,255,255)";
        addView(backView, gPaint);

        let myview = new MyView(); //我的视图
        //添加到框架
        addViewToParent(myview, backView);
        //设置位置
        myview.location = new FCPoint(100, 100);
        //设置大小
        myview.size = new FCSize(200, 200);
        myview.backColor = "rgb(255,0,0)";
        myview.borderColor = "rgb(0,0,0)";
        myview.allowDrag = true;
        myview.allowResize = true;
        updateViewDefault(gPaint.views);
        invalidate(gPaint);

        /*
         * 重置大小
         */
        let resizeAll = function () {
            canvas.width = document.documentElement.clientWidth;
            canvas.height = document.documentElement.clientHeight;
            scaleCanvas(gPaint);
            updateViewDefault(gPaint.views);
            invalidate(gPaint);
        };

        /*
        * 监听大小改变
        */
        window.onresize = function () {
            resizeAll();
        };

        /*
        * 旋转监听
        */
        window.onorientationchange = function () {
            resizeAll();

        };

        updateViewDefault(gPaint.views);
        //刷新界面
        invalidate(gPaint);

        ajaxRequest("GET", "http://qt.gtimg.cn/q=s_sh600519", null,
            function (data) { console.log(data); },
            function (error) { console.log(error); }
        );
    </script>
</body>
</html>
